package com.web.config;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.web.interceptors.LoginInterceptor;
@EnableAspectJAutoProxy
@Configuration
@EnableWebMvc//开启MVC
@ComponentScan(basePackages = {"com.web.config",
								"com.web.controller",
								"com.web.service",
								"com.web.aspect"})
public class SpringWebConfig implements WebMvcConfigurer{
	/**
	 * 配置跨域
	 */
	@Override
	public void addCorsMappings(CorsRegistry registry) {
		// TODO Auto-generated method stub
		registry.addMapping("/**")
		.allowedOrigins("*")
		.allowedMethods("*")
		.allowedHeaders("*")
		.maxAge(3600);
	}
	
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
//	     registry.addInterceptor(new LoginInterceptor())
//	     .addPathPatterns("/space/**")//拦截个人空间下的接口
//	     .addPathPatterns("/note/detail/comment/add");//拦截回复评论的借口
	}

}